<?php

Raise::load('core.RaiseObject');

/**
 * RaiseSingleton abstract class
 * Defines a Singleton class
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @abstract
 * @package phpraise.core.structure
 * @since 1.2
 */
abstract class RaiseSingleton extends RaiseObject {

    /**
     * Prevent creation of a new instance
     * Constructor not set to final to allow overrides in subclass
     */
    protected function __construct() {}

    /**
     * Prevent cloning of the Singleton instance
     * @final
     */
    final private function __clone() {}

    /**
     * Return the Singleton instance
     * @return object
     */
    public final static function instance() {
        static $__instance = null;
        $class = get_called_class();
        return $__instance ? $__instance : $__instance = new $class();
    }
    
}
